/***********************************************
 * Title:       LossStudentExcelHandler.java
 * Description: LossStudentExcelHandler.java
 * Author:      NiDeveloper
 * Create Date: 2010-5-23
 * CopyRight:   CopyRight(c)@2009
 * Company:     TJUSCS
 * Version:     1.0
 ***********************************************
 */
package edu.tju.student;

import java.sql.SQLException;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.younker.waf.db.IBatisConfig;
import com.younker.waf.excelUpload.IResultHandler;

import edu.tju.model.Student;

/**
 * @author NiDeveloper
 *
 */
public class LossStudentExcelHandler implements IResultHandler
{

        protected SqlMapClient sqlMap = IBatisConfig.getSqlMapInstance();
        private static Logger log = Logger.getLogger(StudentExcelHandler.class);
        
        /* (non-Javadoc)
         * @see com.younker.waf.excelUpload.IResultHandler#handle(java.util.List)
         */
        @Override
        public void handle(List<?> beans)
        {
                List<Map<String, Object>> students = (List<Map<String, Object>>) beans;
                Iterator<Map<String, Object>> iter = students.iterator();
                Student student = new Student();
                student.setState(Student.ST_FIRE);
                while (iter.hasNext())
                {
                        Map<String, Object> m = iter.next();
                        String idNo = (String) m.get("idNo");
                        
                        student.setIdNo(idNo);
                        
                        try
                        {
                                sqlMap.update("setStateByIdNo", student);
                        } catch (SQLException e)
                        {
                                log.error("set student state error", e);
                                continue;
                        }
                }
        }

}
